package InheritanceAndPolymorphism.demo06;

public class Test {
    public static void main(String[] args) {
        Animal a;

        a = new Dog();
        a.sing();
        if (a instanceof Dog) {
            Dog dog = (Dog) a;
            dog.guard();
        }

        a = new Cat();
        a.sing();
        if (a instanceof Cat) {
            Cat cat = (Cat) a;
            cat.catchMouse();
        }

        a = new Bird();
        a.sing();
        if (a instanceof Bird) {
            Bird bird = (Bird) a;
            bird.fly();
        }
    }
}
